home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / hity wydania / Ubuntu 9.10 PL / karmelkowy-koliberek-desktop-9.10-i386-PL.iso / casper / filesystem.squashfs / var / lib / dpkg / info / module-init-tools.preinst < prev    next >
Text File  |  2009-09-15  |  4KB  |  118 lines

  1. #!/bin/sh -e
  2. # This script can be called in the following ways:
  3. #
  4. # Before the package is installed:
  5. #    <new-preinst> install
  6. #
  7. # Before removed package is upgraded:
  8. #    <new-preinst> install <old-version>
  9. #
  10. # Before the package is upgraded:
  11. #    <new-preinst> upgrade <old-version>
  12. #
  13. #
  14. # If postrm fails during upgrade or fails on failed upgrade:
  15. #    <old-preinst> abort-upgrade <new-version>
  16.  
  17.  
  18. # Prepare to remove a no-longer used conffile
  19. prep_rm_conffile()
  20. {
  21.     CONFFILE="$1"
  22.  
  23.     if [ -e "$CONFFILE" ]; then
  24.         md5sum="`md5sum \"$CONFFILE\" | sed -e \"s/ .*//\"`"
  25.         old_md5sum="`sed -n -e \"/^Conffiles:/,/^[^ ]/{\\\\' $CONFFILE '{s/ obsolete$//;s/.* //;p}}\" /var/lib/dpkg/status`"
  26.         if [ "$md5sum" != "$old_md5sum" ]; then
  27.             echo "Obsolete conffile $CONFFILE has been modified by you, renaming to .dpkg-bak"
  28.             mv -f "$CONFFILE" "$CONFFILE".dpkg-bak
  29.     else
  30.         mv -f "$CONFFILE" "$CONFFILE".dpkg-obsolete
  31.     fi
  32.     fi
  33. }
  34.  
  35. # Prepare to move a conffile without triggering a dpkg question
  36. prep_mv_conffile() {
  37.     CONFFILE="$1"
  38.  
  39.     if [ -e "$CONFFILE" ]; then
  40.         md5sum="`md5sum \"$CONFFILE\" | sed -e \"s/ .*//\"`"
  41.         old_md5sum="`sed -n -e \"/^Conffiles:/,/^[^ ]/{\\\\' $CONFFILE '{s/ obsolete$//;s/.* //;p}}\" /var/lib/dpkg/status`"
  42.         if [ "$md5sum" = "$old_md5sum" ]; then
  43.             mv -f "$CONFFILE" "$CONFFILE".dpkg-bak
  44.     else
  45.             mv -f "$CONFFILE" "$CONFFILE".dpkg-moving
  46.         fi
  47.     fi
  48. }
  49.  
  50.  
  51. # Prepare to migrate config to 3.7-style
  52. prep_migrate_config_37()
  53. {
  54.     prep_rm_conffile /etc/modprobe.d/aliases
  55.     prep_rm_conffile /etc/modprobe.d/isapnp
  56.     prep_rm_conffile /etc/modprobe.d/options
  57.  
  58.     prep_rm_conffile /etc/modprobe.d/arch/alpha
  59.     prep_rm_conffile /etc/modprobe.d/arch/i386
  60.     prep_rm_conffile /etc/modprobe.d/arch/ia64
  61.     prep_rm_conffile /etc/modprobe.d/arch/m68k.amiga
  62.     prep_rm_conffile /etc/modprobe.d/arch/m68k.atari
  63.     prep_rm_conffile /etc/modprobe.d/arch/m68k.generic
  64.     prep_rm_conffile /etc/modprobe.d/arch/mips
  65.     prep_rm_conffile /etc/modprobe.d/arch/parisc
  66.     prep_rm_conffile /etc/modprobe.d/arch/powerpc.apus
  67.     prep_rm_conffile /etc/modprobe.d/arch/powerpc.generic
  68.     prep_rm_conffile /etc/modprobe.d/arch/powerpc.pmac
  69.     prep_rm_conffile /etc/modprobe.d/arch/s390
  70.     prep_rm_conffile /etc/modprobe.d/arch/sparc
  71.     prep_rm_conffile /etc/modprobe.d/arch/x86_64
  72.  
  73.     prep_rm_conffile /etc/modprobe.d/blacklist-amd76-edac
  74.     prep_mv_conffile /etc/modprobe.d/blacklist \
  75.              /etc/modprobe.d/blacklist.conf
  76.     prep_mv_conffile /etc/modprobe.d/blacklist-firewire \
  77.              /etc/modprobe.d/blacklist-firewire.conf
  78.     prep_mv_conffile /etc/modprobe.d/blacklist-framebuffer \
  79.              /etc/modprobe.d/blacklist-framebuffer.conf
  80.     prep_mv_conffile /etc/modprobe.d/blacklist-watchdog \
  81.              /etc/modprobe.d/blacklist-watchdog.conf
  82. }
  83.  
  84.  
  85. case "$1" in
  86.     install|upgrade)
  87.     # Upgrade from intrepid
  88.     if dpkg --compare-versions "$2" lt "3.7~pre7-1"; then
  89.         prep_migrate_config_37
  90.     fi
  91.     ;;
  92.  
  93.     abort-upgrade)
  94.     ;;
  95.  
  96.     *)
  97.     echo "$0 called with unknown argument \`$1'" 1>&2
  98.     exit 1
  99.     ;;
  100. esac
  101.  
  102. # Automatically added by dh_installinit
  103. if [ "$1" = install ] || [ "$1" = upgrade ]; then
  104.     if [ -e "/etc/init.d/module-init-tools" ] && [ ! -L "/etc/init.d/module-init-tools" ]; then
  105.         if [ "`md5sum \"/etc/init.d/module-init-tools\" | sed -e \"s/ .*//\"`" != \
  106.              "`dpkg-query -W -f='${Conffiles}' module-init-tools | sed -n -e \"\\\\' /etc/init.d/module-init-tools '{s/ obsolete$//;s/.* //p}\"`" ]
  107.         then
  108.             echo "Obsolete conffile /etc/init.d/module-init-tools has been modified by you, renaming to .dpkg-bak"
  109.             mv -f "/etc/init.d/module-init-tools" "/etc/init.d/module-init-tools.dpkg-bak"
  110.         else
  111.             rm -f "/etc/init.d/module-init-tools"
  112.         fi
  113.     fi
  114. fi
  115. # End automatically added section
  116.  
  117. exit 0
  118.